package com.Emotion.emotion.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.Emotion.common.annotation.DataScope;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.Emotion.common.annotation.Log;
import com.Emotion.common.core.controller.BaseController;
import com.Emotion.common.core.domain.AjaxResult;
import com.Emotion.common.enums.BusinessType;
import com.Emotion.emotion.domain.EmotionRecords;
import com.Emotion.emotion.service.IEmotionRecordsService;
import com.Emotion.common.utils.poi.ExcelUtil;
import com.Emotion.common.core.page.TableDataInfo;

/**
 * 情绪检测记录Controller
 * 
 * @author wangtao
 * @date 2025-05-08
 */
@RestController
@RequestMapping("/emotion/records")
public class EmotionRecordsController extends BaseController
{
    @Autowired
    private IEmotionRecordsService emotionRecordsService;

    /**
     * 查询情绪检测记录列表
     */
    @DataScope(deptAlias = "d", userAlias = "u")
    @PreAuthorize("@ss.hasPermi('emotion:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmotionRecords emotionRecords)
    {
        startPage();
        List<EmotionRecords> list = emotionRecordsService.selectEmotionRecordsList(emotionRecords);
        return getDataTable(list);
    }

    /**
     * 导出情绪检测记录列表
     */
    @PreAuthorize("@ss.hasPermi('emotion:records:export')")
    @Log(title = "情绪检测记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmotionRecords emotionRecords)
    {
        List<EmotionRecords> list = emotionRecordsService.selectEmotionRecordsList(emotionRecords);
        ExcelUtil<EmotionRecords> util = new ExcelUtil<EmotionRecords>(EmotionRecords.class);
        util.exportExcel(response, list, "情绪检测记录数据");
    }

    /**
     * 获取情绪检测记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('emotion:records:query')")
    @GetMapping(value = "/{emotionId}")
    public AjaxResult getInfo(@PathVariable("emotionId") Long emotionId)
    {
        return success(emotionRecordsService.selectEmotionRecordsByEmotionId(emotionId));
    }

    /**
     * 新增情绪检测记录
     */
    @PreAuthorize("@ss.hasPermi('emotion:records:add')")
    @Log(title = "情绪检测记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmotionRecords emotionRecords)
    {
        return toAjax(emotionRecordsService.insertEmotionRecords(emotionRecords));
    }

    /**
     * 修改情绪检测记录
     */
    @PreAuthorize("@ss.hasPermi('emotion:records:edit')")
    @Log(title = "情绪检测记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmotionRecords emotionRecords)
    {
        return toAjax(emotionRecordsService.updateEmotionRecords(emotionRecords));
    }

    /**
     * 删除情绪检测记录
     */
    @PreAuthorize("@ss.hasPermi('emotion:records:remove')")
    @Log(title = "情绪检测记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{emotionIds}")
    public AjaxResult remove(@PathVariable Long[] emotionIds)
    {
        return toAjax(emotionRecordsService.deleteEmotionRecordsByEmotionIds(emotionIds));
    }
}
